package com.itchen.hospital.mapper;

import com.itchen.hospital.pojo.User;
import com.itchen.hospital.pojo.Params;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     * 查询所有用户
     * @return
     */
    @Select("select * from user")
    List<User> getAll();

    /**
     * 条件查询用户
     * @param params
     * @return
     */
    List<User> findBySearch(@Param("params") Params params);

    /**
     * 添加用户
     * @param user
     */
    void add(User user);

    /**
     * 修改用户
     * @param user
     */
    void update(User user);

    /**
     * 根据account查询用户
     * @param account
     * @return
     */
    @Select("select * from user where account=#{account}")
    User findByAccount(String account);

    /**
     * 根据account删除用户
     * @param account
     */
    @Delete("delete from user where account=#{account}")
    void delete(String account);

    @Select("select * from user where id=#{id}")
    User getUserById(Integer id);
}
